import md5 from 'js-md5';
import UAParser from 'ua-parser-js'

let ag = undefined;

export default function getAgent() {
  if (!ag) {
    const parser = new UAParser()
    const ua = parser.getUA()

    const agent = ua.toLowerCase();
    const id = md5(agent);
    ag = {
      id,
      ua: agent
    }
  }
  return ag;
}